package innerSortRealize

/**
 * @author liujun
 * @version 1.0
 * @date 2021-06-20 13:09
 * @author—Email liujunfirst@outlook.com
 * @blogURL https://blog.csdn.net/ljfirst
 * @description 选择排序
 */

type SelectSort struct {
}

func (s *SelectSort) SortMethod(array []int) (arr []int) {

	if len(array) == 0 || len(array) == 1 {
		return array
	}
	for i := 0; i < len(array)-1; i++ {
		flag := i
		for j := i + 1; j < len(array); j++ {
			if array[flag] > array[j] {
				flag = j
			}
		}
		if flag != i {
			temp := array[flag]
			array[flag] = array[i]
			array[i] = temp
		}
	}
	return array
}
